package com.glsc.ngateway.platform.domain.costallocation;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author guoj
 * @description: 成本分摊-历史应用详情-ip资产的使用
 * 生成 包括两部分  1）it资产 2）应用详情 3)oa流程触发[/it/oacall]
 * 1>it资产里面新增了就是创建  |
 * it资产里修改了参数（服务器资产没有修改状态），则是修改
 * it资产的虚拟机，云平台删除了是删除
 * @date 2024/8/7 10:50
 */
@Data
@Entity
@Table(name = "t_his_ip_info")
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class HisIpInfo {
    @ApiModelProperty(value = "id")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "l_id", columnDefinition = "int(11) comment '系统ID'")
    private Long id;
    //服务器类型的口径是
    // 若IP从服务器资产的IP1 获取 则为物理机 ，
    // 从虚拟机资产信息获取，则为虚拟机
    // 从 云平台设备获取 则为云平台
    @ApiModelProperty(value = "ip服务器类型-字典项")
    @Column(name = "vc_source_type", columnDefinition = "varchar(10) comment 'ip服务器类型-字典项'")
    private String sourceType;

    @ApiModelProperty(value = "ip")
    @Column(name = "vc_ip", columnDefinition = "varchar(50) comment 'ip'")
    private String ip;

    //从三个菜单初始化
    // 新ip
    @ApiModelProperty(value = "currIp")
    @Column(name = "vc_curr_ip", columnDefinition = "varchar(30) comment 'currIp'")
    private String currIp;
    //老ip
    @ApiModelProperty(value = "oldIp")
    @Column(name = "vc_old_ip", columnDefinition = "varchar(30) comment 'oldIp'")
    private String oldIp;
    @ApiModelProperty(value = "责任人oa账户")
    @Column(name = "vc_system_user_id", columnDefinition = "varchar(500) comment '责任人 逗号分割 多个'")
    private String systemUserId;
    @ApiModelProperty(value = "责任人姓名")
    @Column(name = "vc_system_user_name", columnDefinition = "varchar(500) comment '责任人 逗号分割 多个'")
    private String systemUserName;
    @ApiModelProperty(value = "变更状态")
    @Column(name = "vc_change_status", columnDefinition = "varchar(10) comment '变更状态'")
    private String changeStatus;
    //1）it资产 2）应用详情3)oa流程
    @ApiModelProperty(value = "变更来源")
    @Column(name = "vc_change_source", columnDefinition = "varchar(10) comment '变更来源'")
    private String changeSource;

    //01新增 02变更 03删除
    @ApiModelProperty(value = "变更类型")
    @Column(name = "vc_change_type", columnDefinition = "varchar(10) comment '变更类型'")
    private String changeType;

    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @org.hibernate.annotations.UpdateTimestamp
    @Column(name = "dt_create_time", columnDefinition = "datetime comment '创建时间'")
    protected LocalDateTime createTime;

    //该字段从IT资产外部更新过来 用于应对 ip切换问题
    @ApiModelProperty(value = "唯一标识")
    @Column(name = "vc_unique_key", columnDefinition = "varchar(500) comment '唯一标识'")
    private String uniqueKey;

    @ApiModelProperty(value = "历史应用详情列表")
    @Transient
    private List<HisIpDetailInfo> hisIpDetailInfoList;

    @ApiModelProperty(value = "操作人")
    @Column(name = "vc_operator", columnDefinition = "varchar(50) comment '操作人'")
    private String operator;

    @ApiModelProperty(value = "虚拟机名称，只有虚拟机管理有该字段")
    @Column(name = "vc_virtual_name", columnDefinition = "varchar(500) comment '虚拟机名称，只有虚拟机管理对应该字段'")
    private String virtualName;

    @ApiModelProperty(value = "操作人")
    @Transient
    private String operatorName;
}
